How to ensure that your users always get results.
tables chairs cutlery
and round outdoor table
: the first might reference three different categories of product, and the second might reference only one.apricot
are immediately returned when a user types a
, ap
, apr
.
Algolia doesn’t need to wait for a full-word match before displaying results.
Hence prefix matching helps avoid insufficient results, but you can also use prefix matching to bring back even more results.
By default, Algolia uses a “prefix last” logic, where only the last word in a query is treated as a prefix. All other text in the query must fully match.
For example, the query “ja” will find the sentence “Jack and Jill went up the hill”. But “ja wat” won’t. That’s because only the last term, “wat”, will be used as a prefix, and the unfinished “ja” will be required to match as a complete word, which isn’t possible.
You can get more results by making all text in a query match a prefix. Now “ja wat” will find “Jack and Jill went up the hill” because “ja” matches “Jack”, and “wat” can be ignored.
However, this won’t improve relevance. Only do this when you want some randomness or have many records and care less about relevance. Image search is a good example of when near matches are desirable.